import 'package:firstdemo/navigator/navigatorSecond.dart';
import 'package:firstdemo/util/Toast.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

import 'CustomRouteJianBian.dart';

class navigatorMain extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return new Scaffold(
        appBar: new AppBar(title: new Text("Navigator")),
        body: Padding(
          padding: EdgeInsets.all(12),
          child: Wrap(
            spacing: 10,
            runSpacing: 10,
            children: <Widget>[
              RaisedButton(
                  child: Text(
                    "pushWithValue",
                    style: TextStyle(fontSize: 22),
                  ),
                  textTheme: ButtonTextTheme.accent,
                  onPressed: () async {
                    String result = await Navigator.push(
                        context,
                        new CupertinoPageRoute(
                            builder: (context) => navigatorSecond('is Like?')));
                    ToastUtil.toast("返回值:" + result);
                  }),
              RaisedButton(
                  child: Text(
                    "pop",
                    style: TextStyle(fontSize: 22),
                  ),
                  textTheme: ButtonTextTheme.accent,
                  onPressed: () {
                    ToastUtil.toast('pop');
                    Navigator.pop(context);
                  }),
              RaisedButton(
                  child: Text(
                    "push",
                    style: TextStyle(fontSize: 22),
                  ),
                  textTheme: ButtonTextTheme.accent,
                  onPressed: () {
                    Navigator.push(context,new CupertinoPageRoute(builder: (context) => new navigatorSecond('push')));
                  }),
              RaisedButton(
                  child: Text(
                    "pushNamed",
                    style: TextStyle(fontSize: 22),
                  ),
                  textTheme: ButtonTextTheme.accent,
                  onPressed: () {
                    Navigator.pushNamed(context,'/navigatorSecond');
                  }),
              RaisedButton(
                  child: Text(
                    "定制导航",
                    style: TextStyle(fontSize: 22),
                  ),
                  textTheme: ButtonTextTheme.accent,
                  onPressed: () {
                    Navigator.push(context,new CustomRouteJianBian(new navigatorSecond('push')));
                  })
            ],
          ),
        ));
  }
}
